package com.easyattendance.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.easyattendance.model.Student;
import com.easyattendance.model.StudentLeave;
import com.easyattendance.services.AddAssignmentService;
import com.easyattendance.services.AttendanceService;

@WebServlet(name="AssignmentServlet",urlPatterns="/AssignmentServlet")
public class AssignmentServlet extends HttpServlet{
	 
	protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  
		
	 	response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
	
		/* Get students list  */
		AddAssignmentService assigmentService = new AddAssignmentService();
		
		ArrayList<Student> getStudList=assigmentService.getStudentList(request.getParameter("classid"));
		request.getSession().setAttribute("student_list", getStudList);
		request.getSession().setAttribute("classid",request.getParameter("classid")); 
		request.getSession().setAttribute("subjectid",request.getParameter("subjectid")); 
		request.getSession().setAttribute("assignmentid",request.getParameter("assignmentid")); 
				
		/*RequestDispatcher requetsDispatcherObj =request.getRequestDispatcher("views/teacher/viewAttendanceStudentList.jsp");
		System.out.println("Dispatching....");
		requetsDispatcherObj.forward(request, response);  */
		response.sendRedirect("views/teacher/updateAssignmentSubmission.jsp");
		
	}
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);	
	}
	
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
	}

}
